package com.morningstar.logger.handler;


import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.morningstar.common.entity.LoginLogger;
import com.morningstar.logger.dao.entity.SysLogLogin;
import com.morningstar.logger.service.SysLogLoginService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author yls
 */
@Slf4j
@Service
public class LoggerHandler {

    @Resource
    private SysLogLoginService logLoginService;

    public void handler(String message) {
        LoginLogger logger = JSON.parseObject(message, LoginLogger.class);
        SysLogLogin sysLogLogin = BeanUtil.copyProperties(logger, SysLogLogin.class);
        logLoginService.save(sysLogLogin);
    }
}
